/*
============================================================================
 Name        : TCPSocketTimer.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CTCPSocketTimer implementation
============================================================================
*/

#include "TCPSocketTimer.h"

CTCPSocketTimer::CTCPSocketTimer(MTimerObserver& aObserver)
:CTimer(EPriorityStandard),iObserver(aObserver)
{
	// No implementation required
}


CTCPSocketTimer::~CTCPSocketTimer()
{
}

CTCPSocketTimer* CTCPSocketTimer::NewLC(MTimerObserver& aObserver)
{
	CTCPSocketTimer* self = new (ELeave)CTCPSocketTimer(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CTCPSocketTimer* CTCPSocketTimer::NewL(MTimerObserver& aObserver)
{
	CTCPSocketTimer* self=CTCPSocketTimer::NewLC(aObserver);
	CleanupStack::Pop(); // self;
	return self;
}

void CTCPSocketTimer::ConstructL()
{
	// This is explicitly decareded in the CTimer document
	CTimer::ConstructL();

	// The following line is also essencial!
	CActiveScheduler::Add(this);
}


// public new functions
void CTCPSocketTimer::Start(TInt aSecond)
{
	Cancel();
	After(aSecond * 1000000);
}

// private from CTimer
void CTCPSocketTimer::RunL()
{
	iObserver.OnTimerL(iStatus.Int());
}